{extend name="base" /}
{block name="title"}
<title>教育团队</title>
{/block}
{block name="content"}

<fieldset class="layui-elem-field layui-field-title">
    <legend>
        <span class="layui-breadcrumb">
            <a><cite>教育团队管理</cite></a>
        </span>
    </legend>
    <br>
    <!--<a href="{:url('admin/lunbo/add', ['type' => request()->route('type')])}" class="layui-btn">添加教育团队</a>
    <a href="{:url('admin/lunbo/index', ['type' => request()->route('type')])}" class="layui-btn layui-btn-normal" target="">教育团队列表</a>-->
</fieldset>
<!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>方框风格的表单集合</legend>
</fieldset>-->

<form class="layui-form layui-form-pane" action="" method="post">
    <table class="layui-table">
        <colayui-inputroup>
            <col width="10%">
            <col width="60%">
            <col width="20%">
        </colayui-inputroup>
        <thead>
        <tr>
            <th class="tc">名称</th>
            <th class="tc">输入内容</th>
            <th class="tc">描述</th>
        </tr>
        </thead>
        <tbody>

        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>1.内容区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>小标题1：</th>
            <td>
                <input type="text" class="layui-input" name="title1" placeholder="这里输入内容" value="{$data.title1}">
                <span></span>
            </td>
            <td></td>
        </tr>

        <tr>
            <th><i class="require"></i>内容1：</th>
            <td>
                <textarea class="layui-textarea" name="content1" style="height: 150px;">{$data.content1}</textarea>
            </td>
            <td>
            </td>
        </tr>

        <tr align="center">
            <td  align="center" colspan="3" style="height: 40px;"><b>2.列表区块管理</b></td>
        </tr>
        <tr>
            <th><i class="require"></i>列表管理</th>
            <td class="td-father">
                <div class="father">
                    <div class="site-demo-upload" style="width: 300px; float: left;">
                        <a href="javascript:;" onclick="addImg(this)">[+]</a>
                        <img id="LAY_demo_upload1" src="/html/img/men-3.png" style="width: 200px;height: 200px;border-radius: 100%;">
                        <div class="site-demo-upbar">
                            <input type="file" name="file" class="layui-upload-file" id="test1">
                        </div>
                        <input id="img_url1" class="layui-input" type="text" name="img_url1" value="{$data.img_url1}">
                    </div>
                    <div class="" style="width:600px; float: right;margin-bottom: 25px">
                        标题:<input type="text" class="layui-input">
                        描述:<input type="text" class="layui-input">
                        内容：<textarea placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                    <hr>
                </div>

                <?php for($i = $m; $i< $m+2; $i++) {?>
                <div class="father class-{$i}" style="display: none;">
                    <div class="site-demo-upload" style="width: 300px; float: left;">
                        <a href="javascript:;" onclick="addImg(this)">[+]</a>
                        <img id="LAY_demo_upload{$i}" src="/html/img/men-3.png" style="width: 200px;height: 200px;border-radius: 100%;">
                        <div class="site-demo-upbar">
                            <input type="file" name="file" class="layui-upload-file" id="test{$i}">
                        </div>
                        <input id="img_url{$i}" class="layui-input" type="text" name="img_url{$i}" value="">
                    </div>
                    <div class="" style="width:600px; float: right;margin-bottom: 25px">
                        标题:<input name="team_title[]" type="text" class="layui-input" value="">
                        描述:<input name="team_desc[]" type="text" class="layui-input" value="">
                        内容：<textarea name="team_content[]" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                    <hr>
                </div>
                <?php }?>

            </td>
            <td></td>
        </tr>

        <tr>
            <td colspan="2">
                <div class="layui-form-item">
                    <!--<button class="layui-btn" lay-submit="" lay-filter="sub">提交</button>-->
                    <input type="submit" class="layui-btn" value="提交">
                </div>
            </td>
            <td></td>
        </tr>
        </tbody>
    </table>
</form>
{/block}
{block name="js"}
<script type="text/javascript" src="__ORG__/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','element','upload'], function () {
        var form = layui.form(), layer = layui.layer, layedit = layui.layedit, $ = layui.jquery;

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            name: function (value) {
                if (value.length < 2) {
                    return '标题至少得2个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(sub)', function (data) {
            /*layer.alert(JSON.stringify(data.field), {
             title: '最终的提交信息'
             });*/
            return true;
        });

        // you code ...
        for (var i = 1; i<= 20; i++) {
            layui.upload({
                url: '{:url("/admin/common/upload/type/hdxq")}'
                ,elem: '#test'+i //指定原始元素，默认直接查找class="layui-upload-file"
                //,elem: '.layui-upload-file'
                ,method: 'post' //上传接口的http类型
                ,success: function(datap){
                    layer.msg(datap.msg);
                    if(datap.errno == 0) {
                        if (this.elem.match('#test') == null) {
                            layer.msg('数据有误，清稍后重试');
                            return false;
                        }
                        var num = this.elem.replace(/#test/,'');
                        $('#LAY_demo_upload'+num).attr('src', datap.path);
                        $('#img_url'+num).val(datap.path);
                    }
                }
            });
        }
    });
    function addImg(obj) {
        //var row = $(this).clone();
        var i = $('.td-father > div').length + 1;
        $('.class-'+i).show;
    }
</script>
{/block}